<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <script>
        function $$(id) {
            return document.getElementById(id);
        }
        window.onload = function () {
            var cnv = $$("canvas");
            var cxt = cnv.getContext("2d");
            //半圆
            cxt.beginPath();
            cxt.arc(80, 80, 50, 0, 180 * Math.PI / 180, true);
            cxt.closePath();
            //描边
            cxt.fillStyle = "HotPink";
            cxt.fill();
            //整圆
            cxt.beginPath();
            cxt.arc(120, 80, 50, 0, 360 * Math.PI / 180, true);
            cxt.closePath();
            //描边
            cxt.fillStyle = "#9966FF";
            cxt.fill();
        }
    </script>
</head>

<body><canvas id="canvas" width="200" height="150" style="border:1px dashed gray;"></canvas></body>

</html>